﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameTank
{
    public abstract class VisibleGameEntity: GameEntity
    {
        protected VisibleGameEntity()
        {
            this.childs = new List<VisibleGameEntity>();
        }
        List<VisibleGameEntity> childs;

        public List<VisibleGameEntity> Childs
        {
            get { return childs; }
            set { childs = value; }
        }

        bool enable = true;
        public bool Enable
        {
            get { return enable; }
            set { enable = value; }
        }

        bool visible = true;

        public bool Visible
        {
            get { return visible; }
            set { visible = value; }
        }

        public virtual void Draw(GameTime gameTime, SpriteBatch SBatch)
        {
            for (int i = 0; i < Childs.Count; ++i)
            {
                if (Childs[i].Visible)
                    Childs[i].Draw(gameTime, SBatch);
            }
        }

        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < Childs.Count; ++i)
            {
                if (Childs[i].Enable)
                    Childs[i].Update(gameTime);
            }
        }
    }
}

